package com.loren.tetris.windows;

import com.loren.tetris.data.constant.DataConstant;
import com.loren.tetris.utils.AssistiveUtils;

import javax.swing.*;

public class GameFrame extends JFrame {

    private static final long serialVersionUID = -1208273189880270317L;

    /**
     * setContentPane 一定要在setResizable的后面 否则JPanel的大小不精准
     * setContentPane 一定要在pack的前面 否则JPanel不显示
     * setLocationRelativeTo 一定要在pack的后面 否则窗体不会在中间显示
     */
    public GameFrame() {
        this.setTitle("Java小游戏 - 俄罗斯方块");
        this.setResizable(false);
        this.setContentPane(new GamePanel());
        this.pack();
        this.setLocationRelativeTo(null);
        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        this.setIconImage(AssistiveUtils.getImage(DataConstant.PATH_GAME_ICON));
        this.setVisible(true);
    }

}
